import requests,random
from bs4 import BeautifulSoup

url='https://588ku.com/beijing/renxiang-2-0-default-0-8-0-0-0-0--1/'
payload = {}
headers = {
  'Cookie': '0dea95bdb8093eb2d78be190b8fccf0f=%228-1%22; _var_search_from=%22pic%22; adIssem=0; all_pic_search_words=%5B%22zhongqiu%22%5D; bt_guid=%22adf4d648674c180728ecf4a133be5023%22; f534b0f448272f9dd53a66a49c3ac167=%220a35a8a8059a99fb4f9570dd8c0a57c7%22; keyword=%22%5Cu4e2d%5Cu79cb%22; location=99; no_login_pv=2; qk_host=588ku.com; referer=%22%5C%2F%5C%2F588ku.com%5C%2Fso-tuku%5C%2Fzhongqiu.html%22; search:last:keyword=%22%5Cu4e2d%5Cu79cb%22; source_url=588ku.com',
 'user-agent':'Mozilla/5.0(Windows NT 10.0;Win64;x64) AppleWebKit/537.36 (KHTML,like Gecko)Chrome/127.0.0.0Safari/537.36'
}

html = requests.get( url, headers=headers, data=payload)

# 使用BeautifulSoup将html页面放进一个筛子里，取出需要的信息
soup=BeautifulSoup(html.text,'html.parser')

items=soup.find_all('img',class_='lazy')



# print(items)
urls=[]
for item in items:
    # print(item)
    url = item['data-original']
    # if item['class']==["lazy"]:
    #
    # if item['class']==["img-show"]:
    #     url=item['src']
    url='https:'+url
    urls.append(url)
print(urls)
num=random.randint(0,8888888888888)
for url in urls:
    with open(f'E:/pic/BB/{num}.jpg','wb')as f:
        f.write(requests.get(url, headers=headers,verify=False).content)
        num=num+1